package com.vcc.service.client.vo.userCard;

import com.vcc.core.util.DateUtil;
import com.vcc.core.util.RegexUtil;
import com.vcc.core.util.StringUtil;
import com.vcc.data.entity.Cardholder;
import com.vcc.data.entity.UserCard;
import com.vcc.data.entity.UserCardWallet;
import com.vcc.service.client.vo.baseVo.BaseVo;
import lombok.*;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

@EqualsAndHashCode(callSuper = true)
@Data
@Getter
@Setter
@AllArgsConstructor
public class UserCardVo extends BaseVo implements Serializable {
    /**
     * 账号
     */

    private Long cardGroupId;

    private String groupName;

    private String cardNumber;

    private String cardNumberLastFour;

    private Date requestDate;

    private String orderId;

    private Long cardTypeId;

    private String cardholderId;

    private Long userId;

    private String account;

    private String channelCode;

    private String currencyCode;

    private String currencyName;

    private String cardType;

    private BigDecimal usableQuota;

    private BigDecimal transactionLimit;

    private String remark;

    private String cardStatus;

    private Integer sumCount;

    private Integer successCount;

    private Integer errorCount;

    private BigDecimal sumAmount;

    private BigDecimal successAmount;

    private BigDecimal errorAmount;

    private Integer verifyOpenCardStatus;

    private Integer verifyRechargeCardStatus;

    private Integer verifyOutCardStatus;

    private Integer verifyUpdateLimitStatus;

    private Integer verifyCloseCardStatus;

    private Integer verifyFreezeUnFreezeCardStatus;

    private BigDecimal exchangeRate;

    private String firstName;

    private String lastName;

    private BigDecimal openCardRechargeMinAmount;
    private BigDecimal withdrawMinAmount;
    private BigDecimal rechargeMinAmount;
    private BigDecimal closeCardMinAmount;
    private String withdrawStatus;
    private String closeStatus;

    public UserCardVo() {
    }

    public UserCardVo(UserCardWallet userCardWallet, Cardholder cardholder) {
        this.verifyOpenCardStatus = userCardWallet.getVerifyOpenCardStatus();
        this.verifyRechargeCardStatus = userCardWallet.getVerifyRechargeCardStatus();
        this.verifyOutCardStatus = userCardWallet.getVerifyOutCardStatus();
        this.verifyCloseCardStatus = userCardWallet.getVerifyCloseCardStatus();
        this.verifyFreezeUnFreezeCardStatus = userCardWallet.getVerifyFreezeUnFreezeCardStatus();
        this.exchangeRate = userCardWallet.getExchangeRate();
        this.firstName = RegexUtil.checkObjectIsNull(cardholder) ? null : cardholder.getFirstName();
        this.lastName = RegexUtil.checkObjectIsNull(cardholder) ? null : cardholder.getLastName();
    }


    public UserCardVo(UserCard userCard, UserCardWallet userCardWallet, String account, Cardholder cardholder) {
        super.setId(userCard.getId());
        this.cardNumber = StringUtil.hideCardNumber(userCard.getCardNumber());
        this.requestDate = userCard.getRequestDate();
        this.cardTypeId = userCard.getCardTypeId();
        this.userId = userCard.getUserId();
        this.account = StringUtil.hideMobile(account);
        this.channelCode = userCard.getChannelCode();
        this.currencyCode = userCard.getCurrencyCode();
        this.currencyName = userCard.getCurrencyName();
        this.cardType = userCard.getCardType();
        this.usableQuota = userCard.getUsableQuota();
        this.remark = userCard.getRemark();
        this.cardStatus = userCard.getCardStatus();
        this.sumCount = userCard.getSumCount();
        this.successCount = userCard.getSuccessCount();
        this.errorCount = userCard.getErrorCount();
        this.sumAmount = userCard.getSumAmount();
        this.successAmount = userCard.getSuccessAmount();
        this.errorAmount = userCard.getErrorAmount();
        this.verifyOpenCardStatus = userCardWallet.getVerifyOpenCardStatus();
        this.verifyRechargeCardStatus = userCardWallet.getVerifyRechargeCardStatus();
        this.verifyOutCardStatus = userCardWallet.getVerifyOutCardStatus();
        this.verifyCloseCardStatus = userCardWallet.getVerifyCloseCardStatus();
        this.verifyFreezeUnFreezeCardStatus = userCardWallet.getVerifyFreezeUnFreezeCardStatus();
        this.exchangeRate = userCardWallet.getExchangeRate();
        this.firstName = RegexUtil.checkObjectIsNull(cardholder) ? null : cardholder.getFirstName();
        this.lastName = RegexUtil.checkObjectIsNull(cardholder) ? null : cardholder.getLastName();
    }
}
